<?php
/**
 * This file is part of Swoft.
 *
 * @link https://swoft.org
 * @document https://doc.swoft.org
 * @contact group@swoft.org
 * @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
 */

namespace App\Controllers;

use Swoft\HttpClient\Client;
use Swoft\Http\Server\Bean\Annotation\Controller;

/**
 * @Controller(prefix="/httpClient")
 */
class HttpClientController
{
    /**
     * @return array
     * @throws \Swoft\HttpClient\Exception\RuntimeException
     * @throws \RuntimeException
     * @throws \InvalidArgumentException
     */
    public function request(): array
    {
        $client = new Client(['timeout' => 15]);
        $result = $client->get('http://mike.io/demo.php')->getResult();
        // $result = $client->get('http://api.j-pay.com.cn/other/getlastflowchannel2.php?option=all&userid=10000&fs=10009&vstr=67c2e215cf679a3b0898e176bd5a2ca2')->getResult();
        // $result = $client->get('http://api.shenzhouka.com/phone/account_money.aspx')->getResponse()->getBody()->getContents();
        // $result = $client->request('get', 'http://api.shenzhouka.com/phone/account_money.aspx')->getResult();
        // return [iconv('GB2312', 'UTF-8//IGNORE', $result)];
        return [$result];
    }
}